<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<%@ page isELIgnored="false"%>
<html>
	<head>
		<title>员工任务跟踪-Iframe-SJH</title>
	</head>
<e:View id="eView" designProperty="width: 1024; height: 768">
	<script type="text/javascript" src="<c:url value='/scripts/global.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/scripts/skin.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/js/perform/perform.js'/>"></script>
	
	<div id="Invisual Controls" style="min-height: 40px;">
	<!--考核阶段 -->
		<e:Dataset id="Dataset_project_segment" pageSize="-1">
			<e:Field name="segmentId" label="分段ID" dataType="string"/>
			<e:Field name="projectId" label="考核方案ID" dataType="string"/>
			<e:Field name="cycleId" label="阶段周期ID" dataType="string"/>
			<e:Field name="segmentName" label="考核阶段名称" dataType="string"/>
			<e:Field name="status" label="状态" dataType="string"/>
			<e:Field name="startDate" label="开始日期" dataType="date"/>
			<e:Field name="endDate" label="结束日期" dataType="date"/>
			<e:Field name="scoreTime" label="计算时间"  dataType="date"/>
			<e:Field name="cycleName" label="阶段周期名称"  dataType="string"/>
		</e:Dataset>
	<!-- 考核方案-指标 -->
		<e:Dataset id="Dataset_project_index" pageSize="-1">
			<e:Field name="projectId" dataType="string"/>
			<e:Field name="indexId" dataType="string"/>
			<e:Field name="indexType" dataType="string"/>
			<e:Field name="indexUnit" dataType="string" label="指标单位"/>
			<e:Field name="scale" dataType="string" label="指标小数位"/>			
			<e:Field name="indexName" dataType="string" label="指标名称"/>
		</e:Dataset>		
	<!--任务对应员工-->
		<e:Dataset id="Dataset_task_user" pageSize="-1" confirmDelete="false" confirmCancel="false">
			<e:Field name="taskId" dataType="string" label="任务ID" maxLength="32" visible="false"/>
			<e:Field name="taskName" dataType="string" label="任务名称" maxLength="200" visible="false"/>
			<e:Field name="segmentId" dataType="string" label="考核分段ID" maxLength="32" visible="false"/>
			<e:Field name="userId" dataType="string" label="员工ID" maxLength="32" readOnly="true" />
			<e:Field name="userName" label="员工名称" dataType="string" readOnly="true" />
			<e:Field name="orgName" label="员工所属机构" dataType="string" readOnly="true" />			
		</e:Dataset>
		
		<e:Command id="Command_export"  action="com.longtop.perform.khyg.web.TaskAction" method="exportTaskTrack" showHintInfoOnSuccess="false">
			<e:DatasetInfo name="info" dataset="Dataset_project_index" submitType="all"></e:DatasetInfo>
			<e:Parameter name="segmentId" value=""></e:Parameter>
		</e:Command>		

<body style="overflow: auto">
<e:Page id="ePage" action="com.longtop.perform.khyg.web.TaskAction" style="min-height: 80px; width: 100%; height: 100%;"  onAfterLoadPage="ePage_onAfterLoadPage()" onBeforeLoadPage="ePage_onBeforeLoadPage()">
	<table width="100%"  border="0" cellpadding="2" cellspacing="2">
		<tr>
			<td>
				<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td height="27px" width="1%">
							<e:RecordNavigator id="RecordNavigator_segmentUser" dataset="Dataset_task_user" showNavigatorButton="false">
								<e:RecordButton id="RecordButton_choose" label="查询考核对象" onClick="RecordButton_choose_onClick()"  icon="/images/query.gif"></e:RecordButton>
            					<e:RecordButton id="RecordButton_export" label="导出Excel" onClick="RecordButton_export_onClick()"  icon="/images/export.gif"></e:RecordButton>
							</e:RecordNavigator>
						</td>
						<td align="left" width="99%">
							<div id="dataResult"></div>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<!-- 员工任务数据： -->
				<e:Grid id="Grid_segmentUser" style="width: 100%; height: 100%;" showIndex="true" dataset="Dataset_task_user" readOnly="true">
				</e:Grid>
			</td>
		</tr>	
	<table>
</e:Page>
</body>
<script language="Javascript">
	//init:
	function ePage_onBeforeLoadPage(){
		
	}
	function ePage_onAfterLoadPage(){
		if($J("Grid_segmentUser").isEmpty()){
			$J("RecordNavigator_segmentUser").setEnabled(false);
			var dataResultDiv = document.getElementById("dataResult");
			dataResultDiv.innerHTML="<font color='red'>* 该考核方案阶段尚未分配任何考核对象。<font/>"					
		}
	}
	//选择考核对象
	function RecordButton_choose_onClick(){
		var segmentId = Dataset_project_segment.getValue('segmentId');		
		var arrayMap = selectTaskUsersFromWindow(segmentId);//选择考核周期对应员工弹出框
		if(arrayMap == ''){
			return;
		}
		var recordArray = Dataset_task_user.records;
		var record;
		for(var j=0; j<recordArray.length; j++){
			record = recordArray.get(j);
			var isExist = false;
			for (var i =0 ; i<arrayMap.length ; i++){
				if(record.getValue("userId") == arrayMap[i].get("userId")){
					isExist = true;
					break;
				}
			}
			if(isExist){//设置选择的员工状态为显示
				Dataset_task_user.setRecordCurrentState(record, Constant.RECORD.NONE);
			}else{
				Dataset_task_user.setRecordCurrentState(record, Constant.RECORD.STATE_DELETE);
			}
		}
		Dataset_task_user.refreshControls();
	}
	
	//导出excel:
	function RecordButton_export_onClick(){
		var segmentId = Dataset_project_segment.getValue('segmentId');
		Command_export.parameters.setValue("segmentId",segmentId);
		Command_export.execute();
	}
</script>
</e:View>
</html>